<extend name="./public/frame.html"/>
<block name="content">
	<style>
		.layui-form-label{width: 10%;}
		.layui-input-block{margin-left: 12%;}
	</style>
	<h2 style="text-align: center;">车辆保险</h2>
	<form class="layui-form layui-form-pane1" method="post" id="formId" autocomplete="off">
		<input type="hidden" name="car_id" value="{$car_id}">
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>车辆车牌号</label>
			<div class="layui-input-inline">
			  <input type="text" name="vehicleLicense" lay-verify="required" value="{$data.vehicleLicense}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">车辆车牌号</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>保险公司</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceCompany" lay-verify="required" value="{$data.insuranceCompany}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">保险公司</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>保险号</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceCode" lay-verify="required" value="{$data.insuranceCode}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">保险号</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>'保险类别</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceType" lay-verify="required" value="{$data.insuranceType}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">'保险类别</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>保险金额</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceAmount" lay-verify="required" value="{$data.insuranceAmount}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">保险金额</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>保险生效时间</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceValidDate" lay-verify="required" id="insuranceValidDate" value="{$data.insuranceValidDate}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">保险生效时间</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>保险到期时间</label>
			<div class="layui-input-inline">
			  <input type="text" name="insuranceEndDate" lay-verify="required" id="insuranceEndDate" value="{$data.insuranceEndDate}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">保险到期时间</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"><i style="color:red;font-size: 28px;vertical-align: bottom;">*</i>网约车运输证号</label>
			<div class="layui-input-inline">
			  <input type="text" name="certificateNo" value="{$data.certificateNo}" class="layui-input">
			</div>
			<div class="layui-form-mid layui-word-aux">网约车运输证号</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit id="submits">立即提交</button>
			</div>
		</div>
	</form>

	<script>
		layui.use(['laydate', 'upload','form'], function () {
			var laydate = layui.laydate
				,upload = layui.upload
				,form = layui.form
			;
			upload.render({
				elem: '#test3'//这个就等同于点击
				,url: '/admin/Upload/base64EncodeImage'
				,before: function(obj){

				}
				,done:  function(res){ //上传后的回调
					console.log(res)
					if(res.status == 1){
						$("#demo3").attr('src',res.base_img);
						$("#legalIdCardPhoto").val(res.base_img);


					}else{
						layer.msg(res.msg,{'icon':2});
					}
				},
				error: function(e){
					console.log(e)
				  //layer.msg('上传失败');

				}
			});
            laydate.render({
                elem: '#insuranceValidDate'
            });
            laydate.render({
                elem: '#insuranceEndDate'
            });
            $("#submits").click(function () {
                var formStr = $("#formId").serialize();
                //序列化中文时之所以乱码是因为.serialize()调用了encodeURLComponent方法将数据编码了
                //原因：.serialize()自动调用了encodeURIComponent方法将数据编码了
                //解决方法：调用decodeURIComponent(XXX,true);将数据解码
                var params = decodeURIComponent(formStr,true); //关键点
				$.post('/admin/System/clbx_submits',{
				    data:params
				},function(res){
                    if (res.code === 1) {
                        alert(res.msg);
                        window.location.reload();

                        //向java 提交 交通部接口数据
                        ajax_post_java(params);
                    } else {
                        alert(res.msg);
                    }
				});
				return false;
            });

		});

        function ajax_post_java(params) {
            $.post("/admin/System/ajax_clbx", {
                data : params
            }, function (res) {
                if (res.code === 1) {
                    console.log(res.msg);
                } else {
                    console.log(res.msg);
                }
            }, 'json');
        }

	</script>
</block>
